<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<?php
/**
 * Created by PhpStorm.
 * User: dapeng
 * Date: 2018/9/27
 * Time: 下午4:44
 */


$id = $_GET["id"];

//1连接数据库
try{
    $pdo = new PDO("mysql:host=localhost;dbname=test","root","");
}catch (Exception $e){
    var_dump($e);
    die("连接失败");
}

//2、组装删除语句
$insertSQL = "DELETE FROM tbl_user WHERE id = $id";//

//3、执行删除语句
$res = $pdo -> exec($insertSQL);//普遍用户增删改,返回结果是一个整型,1 2

if ($res > 0){
    echo "<meta http-equiv=\"refresh\" content=\"1; url=userlist.php\">";
    print('删除成功,正在拼命的跳转页面...<br>1秒后自动跳转~~~');

}else{
    echo "删除失败";
    var_dump($pdo->errorInfo());
}